package gui.visu.listeners;


import gui.utils.IntegerField;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import tuio.components.SliderTouch;


/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class ListenerSlider implements ChangeListener{

	private SliderTouch slider;
	private IntegerField linkedField;

	public ListenerSlider(SliderTouch slider, IntegerField linkedField){
		this.setSlider(slider);
		this.setLinkedField(linkedField);
	}

	public ListenerSlider(){
		this.setLinkedField(null);
	}

	@Override
	public void stateChanged(ChangeEvent e) {
		if(this.getLinkedField() != null){
			this.getLinkedField().setText(String.valueOf(this.getSlider().getValue()));
		}
	}

	public void setSlider(SliderTouch slider) {
		this.slider = slider;
	}

	public SliderTouch getSlider() {
		return slider;
	}

	public void setLinkedField(IntegerField linkedField) {
		this.linkedField = linkedField;
	}

	public IntegerField getLinkedField() {
		return linkedField;
	}









}

